#include "Camera.h"
#include <gl.h>

Camera::Camera()
{

	xPos = 0;
	yPos = 0;
	zPos = 0;

	angle = 0;
	xVec = 0;
	yVec = 0;
	zVec = 0;

	xRot = 0;
	yRot = 0;
	zRot = 0;
}

Camera::~Camera()
{

}

void Camera::setPosition(double _x, double _y, double _z)
{
	pos[0] = _x;
	pos[1] = _y;
	pos[2] = _z;
}

void Camera::setRotation(double _angle, double _x, double _y, double _z)
{
	EulerRot = false;
	vecRot = true;
	angle = _angle;
	xVec = _x;
	yVec = _y;
	zVec = _z;
}

void Camera::setRotation(double _x, double _y, double _z)
{
	EulerRot = true;
	vecRot = false;
	xRot = _x;
	yRot = _y;
	zRot = _z;
}

void Camera::translate(double _x, double _y, double _z)
{
	pos[0] += _x;
	pos[1] += _y;
	pos[2] += _z;
}

void Camera::rotate(double _x, double _y, double _z)
{
	EulerRot = true;
	vecRot = false;
	xRot += _x;
	yRot += _y;
	zRot += _z;
}

float* Camera::getPosition()
{
	return pos;
}

void Camera::draw()
{
	if(EulerRot)
	{
		glRotated(-xRot, 1, 0, 0);
		glRotated(-yRot, 0, 1, 0);
		glRotated(-zRot, 0, 0, 1);
	}
	else
		glRotated(-angle, xVec, yVec, zVec);

	glTranslated(-pos[0],-pos[1],-pos[2]);
}
